<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Util extends CI_Controller {       //用于上传图片的控制器，
	public function upload(){
		// if ($_FILES['file']['error']>0){
		// 	exit("上传错误");
		// }else{
		// 	$path='./uploads/'.$_FILES['file']['name'];
		// 	move_uploaded_file($_FILES['file']['tmp_name'],$path);
		// 	echo 'uploads/'.$_FILES['file']['name'];
		// }
		$config['upload_path']      = './uploads/';//自定义上传目录
        $config['allowed_types']    = 'gif|jpg|png';//自定义上传格式	
        $config['max_size']     = 0;//自定义上传大小
        $config['max_width']        = 10240;//自定义上传宽度
        $config['max_height']       = 7680;//自定义上传长度

        $this->load->library('upload', $config);//限制条件加载进入上传
        if ( ! $this->upload->do_upload('file')){//判断上传文件的类型
            echo  $this->upload->display_errors();//报错，此文件超出限制条件。
            //$this->load->view('upload_form', $error);
        }
        else{
            $data =  $this->upload->data("file_name");
            echo './uploads/'.$data;
            // $this->load->view('admin/Article/add', $data);
        }
	}
}
